def concat(file1, file2, file3):
  # 打开 file1 和 file2 读取内容
  with open(file1, "r") as f1, open(file2, "r") as f2:
    c1 = f1.read()
    c2 = f2.read()

  # 将 file1 和 file2 的内容合并
    together = c1 + c2

  # 将合并后的内容写入 file3
  with open(file3, "w") as f3:
    f3.write(together)

  f1.close()
  f2.close()
  f3.close()
# 示例调用

if __name__ == '__main__':
  file1 = "file1.txt"
  file2 = "file2.txt"
  file3 = "file3.txt"
  concat(file1, file2, file3)
